package com.qpx.jxcmessage.dlx;


import com.alibaba.fastjson.JSON;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@Component
public class ProducerDTX {

    @Autowired
    RabbitTemplate rabbitTemplate;

    /**
     * 订单创建成功后调用此方法
     * @param orderNo
     */
    public void sendMessage(String orderNo) throws InterruptedException {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("orderNo",orderNo);
        rabbitTemplate.convertAndSend("order_exchange","order.#", JSON.toJSONString(map));
        TimeUnit.SECONDS.sleep(5);
        System.out.println("支付成功,删除队列");

    }
}
